import request from '@/api/axios'
import {AxiosPromise} from 'axios'
import {DataRes, Paging} from '@/api/config'

// 健教大类 bigType bigTypeName
// 健教小类 smallType smallTypeName
// ICD-10疾病编码 icdCode icdCodeName
// 健教名称 name
// 业务类型 businessType businessTypeName
// ICD-10疾病编码展示 icdCodes

export interface icCodeLists{
  id?:number
  icdCode?:string|null,
  icdCodeName?:string|null,
}
//健教指导分页查询数据定义
export interface GetHealthGuideList extends Paging{
  name?:string|null,
  icdCodes?:string|null,
  businessType?:string|null,
  businessTypeName?:string|null
  bigType?:string|null,
  bigTypeName?:string|null,
  smallType?:string|null,
  smallTypeName?:string|null
  icdCodeList?:Array<icCodeLists>
}
// 搜索数据定义
export interface SearchHealthGuideFromData{
  name?:string|null,
  businessType?:string|null,
  bigType?:string|null,
}

//表头按钮定义
export type TableOperation='add'

// 健教指导基本信息
export interface BaseHealthGuideInfor{
  name:string,
  icdCodeList:Array<icCodeLists>,
  icdCodes:string,
  businessType:number,
  businessTypeName:string
  bigType:number
  bigTypeName:string
  smallType:number|null
  smallTypeName:string
}

//健教指导信息
export interface HealthGuideInfor extends BaseHealthGuideInfor{
  id:string
}

export type HealthGuideFormInfor = Partial<HealthGuideInfor>

export interface HealthGuideInforList {
  size:number
  total:number
  records:Array<HealthGuideInfor>
}

//获取健教指导列表
export const getHealthGuideList = (params:GetHealthGuideList):AxiosPromise<DataRes<HealthGuideInforList>> => {
  return request({
    url:'/api/healthGuide/page',
    method:'get',
    params
  })
}

//保存修改健教指导信息
export const saveHealthGuideInfor = (data:HealthGuideFormInfor):AxiosPromise<DataRes<undefined>> => {
  return request({
    url:'/api/healthGuide/saveOrUpdate',
    method:'post',
    data
  })
}

// 删除健教指导信息
export const deleteHealthGuide = (id:string):AxiosPromise<DataRes<undefined>> => {
  return request({
    url:'/api/healthGuide/' + id,
    method:'post'
  })
}

// 健教指导健康内容基本信息
export interface BaseHealthGuideScanInfor{
  healthGuideId:string
  healthValue:string
}

//健教指导健康内容信息
export interface HealthGuideScanInfor extends BaseHealthGuideScanInfor{
  id:string
}

export type HealthGuideFormScanInfor = Partial<HealthGuideScanInfor>


//获取健教指导健康内容列表
export const getHealthScanList = (healthGuidId:string):AxiosPromise<DataRes<Array<HealthGuideScanInfor>>> => {
  return request({
    url:'/api/healthGuideConfiguration/list/' + healthGuidId,
    method:'get'
  })
}

//保存修改健教指导健康内容信息
export const saveHealthScanInfor = (healthGuidId:string, data:Array<HealthGuideFormScanInfor>):AxiosPromise<DataRes<undefined>> => {
  return request({
    url:'/api/healthGuideConfiguration/batchSaveOrUpdate/' + healthGuidId,
    method:'post',
    data
  })
}

// 删除健教指导健康内容信息
export const deleteHealthScanGuide = (id:string):AxiosPromise<DataRes<undefined>> => {
  return request({
    url:'/api/healthGuideConfiguration/' + id,
    method:'post'
  })
}

//获取ICD-10疾病编码列表事件
export const getCodeList = (params:{icdCode?:string, icdCodeName?:string}):AxiosPromise<DataRes<Array<icCodeLists>>> => {
  return request({
    url:'/api/icdCode/search/list',
    method:'get',
    params
  })
}
